﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_PRODUCT.Product.DAO;
using ERP_RORZE_DLL.Product.Base;

namespace ERP_RORZE_PRODUCT.Product.LINK_VCUONGDATABASE
{
    public partial class ctrlOther : DevExpress.XtraEditors.XtraUserControl
    {
        DataTable dt;
        ClsLinkVCuongDAO clsLVDAO = new ClsLinkVCuongDAO();

        public ctrlOther()
        {
            InitializeComponent();
        }

        private void ListItem()
        { 
            //ZDH 
            //XThanh_LayNCtamthoi
            //VitrihangVIA_KTRA
            //VitrihangMAY_VIA
            //VanthongkedulieuXLBM
            //VanthongkedulieuVIA
            //VanthongkedulieuKTra
            //Udonhang
            //UDH_KH
            //TK-HoanthanhKHtrongthang
            //TK-Congsuatmay
            //TK-CongsuatKHVia
            //TK_CongsuatKHKtra
            //QStaffDailyTime
            //QMachineDailyTime
            //P_InsData-Luu
            //Le-Laydulieu PIN1
            //KH-TGconlaicuadonhang02
            //KH-TGconlaicuadonhang01
            //KH-DonhangchuaXINLENH
            //KH-DonhangchuaSTART
            //InsTime- Thanh0673
            cbStore.Items.Add("ZDH");//0
            cbStore.Items.Add("XThanh_LayNCtamthoi");//1
            cbStore.Items.Add("VitrihangVIA_KTRA");//2
            cbStore.Items.Add("VitrihangMAY_VIA");//3
            cbStore.Items.Add("VanthongkedulieuXLBM");//4
            cbStore.Items.Add("VanthongkedulieuVIA");//5
            cbStore.Items.Add("VanthongkedulieuKTra");//6
            cbStore.Items.Add("Udonhang");//7
            cbStore.Items.Add("UDH_KH");//8
            cbStore.Items.Add("TK-HoanthanhKHtrongthang");//9
            cbStore.Items.Add("TK-Congsuatmay");//10
            cbStore.Items.Add("TK-CongsuatKHVia");//11
            cbStore.Items.Add("TK_CongsuatKHKtra");//12
            cbStore.Items.Add("QStaffDailyTime");//13
            cbStore.Items.Add("QMachineDailyTime");//14
            cbStore.Items.Add("P_InsData-Luu");//15
            cbStore.Items.Add("Le-Laydulieu PIN1");//16
            cbStore.Items.Add("KH-TGconlaicuadonhang02");//17
            cbStore.Items.Add("KH-TGconlaicuadonhang01");//18
            cbStore.Items.Add("KH-DonhangchuaXINLENH");//19
            cbStore.Items.Add("KH-DonhangchuaSTART");//20
            cbStore.Items.Add("InsTime- Thanh0673");//21
            cbStore.Items.Add("KH-TGGCcacdonhangtinhKH02");//22
            cbStore.Items.Add("P_LayNClamKHGcong03");//23
            cbStore.Items.Add("P_LayNClamKHVia");//24
            cbStore.Items.Add("P_LayNClamKHKtra");//25
            cbStore.Items.Add("TK_CongsuatKHKtra-Hoan");//26

        }

        private void cbStore_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (cbStore.SelectedIndex.ToString() == "0")
            {

                dt = clsLVDAO.ZDH();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "1")
            {

                dt = clsLVDAO.XThanh_LayNCtamthoi();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "2")
            {

                dt = clsLVDAO.VitrihangVIA_KTRA(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "3")
            {

                dt = clsLVDAO.VitrihangMAY_VIA(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "4")
            {

                dt = clsLVDAO.VanthongkedulieuXLBM(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "5")
            {

                dt = clsLVDAO.VanthongkedulieuVIA(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "6")
            {

                dt = clsLVDAO.VanthongkedulieuKTra(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "7")
            {

                dt = clsLVDAO.Udonhang();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "8")
            {

                dt = clsLVDAO.UDH_KH();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "9")
            {

                dt = clsLVDAO.TK_HoanthanhKHtrongthang(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "10")
            {

                dt = clsLVDAO.TK_Congsuatmay(dateDateFrom.Value.Date, dateDateTo.Value.Date);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "11")
            {

                dt = clsLVDAO.TK_CongsuatKHVia();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "12")
            {

                dt = clsLVDAO.TK_CongsuatKHKtra();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "13")
            {

                dt = clsLVDAO.QStaffDailyTime();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "14")
            {

                dt = clsLVDAO.QMachineDailyTime();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "15")
            {

                dt = clsLVDAO.P_InsData_Luu();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "16")
            {

                dt = clsLVDAO.Le_LaydulieuPIN1();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "17")
            {

                dt = clsLVDAO.KH_TGconlaicuadonhang02(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "18")
            {

                dt = clsLVDAO.KH_TGconlaicuadonhang01();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "19")
            {

                dt = clsLVDAO.KH_DonhangchuaXINLENH(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "20")
            {

                dt = clsLVDAO.KH_DonhangchuaSTART(dateDateFrom.Value, dateDateTo.Value);
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "21")
            {

                dt = clsLVDAO.InsTime_Thanh0673();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "22")
            {

                dt = clsLVDAO.GetAllKHTon();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "23")
            {

                dt = clsLVDAO.GetAllKHGC03();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "24")
            {

                dt = clsLVDAO.GetAllKHNCV24();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "25")
            {

                dt = clsLVDAO.GetAllKHNCV25();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            else if (cbStore.SelectedIndex.ToString() == "26")
            {

                dt = clsLVDAO.GetAllKHNCV26();
                gridControl1.DataSource = dt;
                gridView1.PopulateColumns();
                gridView1.BestFitColumns();
            }
            Cursor.Current = Cursors.Default;
        }

        private void ctrlOther_Load(object sender, EventArgs e)
        {
            ListItem();
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            clsConstantsFuction.ExportToExcel(gridView1, 1, true);
        }
    }
}
